package com.hxx.day7;

import org.junit.Test;

public class TestDemo3 {

    /**
     * 测试线程的优先级
     * @param args
     */
    public static void main(String[] args) {
        //创建线程
        Runnable runnable = () -> {
            for (int index = 0; index < 10; index++) {
                System.out.println(Thread.currentThread().getName()+"---线程执行了"+index+"次");
            }
        };
        Thread thread1 = new Thread(runnable,"线程1");
        Thread thread2 = new Thread(runnable,"线程2");

        //设置线程的优先级
        thread1.setPriority(Thread.MAX_PRIORITY);
        thread2.setPriority(Thread.MIN_PRIORITY);

        thread1.start();
        thread2.start();
    }
}
